package com.arpa.wms.domain.entity;

import com.arpa.wms.domain.enums.BillingUnitEnum;
import com.arpa.wms.domain.enums.StorageFeeTypeEnum;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.apache.ibatis.type.JdbcType;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Digits;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;

/**
 * <p>
 * 仓库计费合同
 * </p>
 *
 * @author LEO
 * @since 2020-11-17
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("wms_contract")
@ApiModel(value = "Contract对象", description = "仓库计费合同")
public class Contract extends BasicEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "合同标识",hidden = true)
    @TableField("code")
    private String code;

    @ApiModelProperty(value = "合同号",required = true)
    @NotNull(message = "合同号不能为空")
    @Length(min = 0, max = 100, message = "合同号长度不能超过100")
    @TableField("contract_no")
    private String contractNo;

    @ApiModelProperty(value = "仓库标识",required = true)
    @NotNull(message = "仓库不能为空")
    @TableField("warehouse_code")
    private String warehouseCode;

    @ApiModelProperty(value = "仓库名称",required = true)
    @NotNull(message = "仓库名称不能为空")
    @TableField("warehouse_name")
    private String warehouseName;

    @ApiModelProperty(value = "货主标识",required = true)
    @NotNull(message = "货主不能为空")
    @TableField("shipment_code")
    private String shipmentCode;

    @ApiModelProperty(value = "货主名称",required = true)
    @NotNull(message = "货主名称不能为空")
    @TableField("shipment_name")
    private String shipmentName;

    @ApiModelProperty(value = "所属机构", hidden = true)
    @TableField("group_code")
    private String groupCode;

    @ApiModelProperty(value = "生效日期",required = true)
    @NotNull(message = "生效日期不能为空")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @TableField("gmt_effective")
    private LocalDate gmtEffective;

    @ApiModelProperty(value = "失效日期",required = true)
    @NotNull(message = "失效日期不能为空")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @TableField("gmt_ineffective")
    private LocalDate gmtIneffective;

    @ApiModelProperty(value = "开始计费日期",required = true)
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @TableField("gmt_billing_begin")
    private LocalDate gmtBillingBegin;

    @ApiModelProperty(value = "仓储费类型：WHOLE（包仓），SCATTERED（零散）",required = true)
    @NotNull(message = "仓储费类型不能为空")
    @TableField("storage_fee_type")
    private StorageFeeTypeEnum storageFeeType;

    @ApiModelProperty(value = "计费单位：包仓（LOCATION（库位），AREA（面积）），零仓（PIECE（件），TON（吨），LOCATION（库位））")
    @TableField("billing_unit")
    private BillingUnitEnum billingUnit;

    @ApiModelProperty(value = "计费周期",required = true)
    @NotNull(message = "计费周期不能为空")
    @Max(value = 99999999, message = "请输入正确的计费周期")
    @TableField("billing_cycle")
    private Integer billingCycle;

    @ApiModelProperty(value = "单价")
    @Min(value = 0, message = "请输入正确的单价")
    @Digits(integer = 20, fraction = 6, message = "请输入正确的单价")
    @TableField(value ="unit_price",updateStrategy = FieldStrategy.IGNORED,jdbcType = JdbcType.DECIMAL)
    private BigDecimal unitPrice;

    @ApiModelProperty(value = "数量(包仓)")
    @Min(value = 0, message = "请输入正确数量")
    @Digits(integer = 20, fraction = 6, message = "请输入正确数量")
    @TableField("quantity")
    private BigDecimal quantity;

    @ApiModelProperty(value = "总金额(包仓)")
    @TableField("amount_money")
    private BigDecimal amountMoney;

    @ApiModelProperty(value = "最小计费量(零散)")
    @Min(value = 0, message = "请输入正确的最小计费量")
    @Digits(integer = 20, fraction = 6, message = "请输入正确的最小计费量")
    @TableField(value = "min_billing_volume",updateStrategy = FieldStrategy.IGNORED,jdbcType = JdbcType.DECIMAL)
    private BigDecimal minBillingVolume;

    @ApiModelProperty(value = "备注")
    @Length(min = 0, max = 100, message = "备注长度不能超过100")
    @TableField(value = "remarks",updateStrategy = FieldStrategy.IGNORED,jdbcType = JdbcType.VARCHAR)
    private String remarks;

    @ApiModelProperty(value = "状态：0启用、1停用", hidden = true)
    @TableField("status")
    private String status;

    @ApiModelProperty(value = "附件")
    @TableField("attachment_url")
    private String attachmentUrl;
    @ApiModelProperty(value = "附件名称")
    @TableField("attachment_name")
    private String attachmentName;


    //@Valid
    @ApiModelProperty(value = "作业费")
    @TableField(exist = false)
    private List<ContractOperationCost> contractOperationCostList;

    public interface Save {

    }

    public interface Update {

    }
}
